home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Src / submit / auth_ut.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  3.5 KB  |  233 lines

  1. /* auth_ut.c: authorisation utilities */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Src/submit/RCS/auth_ut.c,v 6.0 1991/12/18 20:28:02 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Src/submit/RCS/auth_ut.c,v 6.0 1991/12/18 20:28:02 jpo Rel $
  9.  *
  10.  * $Log: auth_ut.c,v $
  11.  * Revision 6.0  1991/12/18  20:28:02  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "util.h"
  19. #include "q.h"
  20. #include <varargs.h>
  21.  
  22. extern char        auth2submit_msg[];
  23.  
  24.  
  25. /* -- local routines -- */
  26. void            authchan_add();
  27. void            authmta_add();
  28. void            do_reason();
  29. AUTH            *auth_new();
  30. AUTH_USER        *authusr_new();
  31. LIST_AUTH_CHAN        *authchan_new();
  32. LIST_AUTH_MTA        *authmta_new();
  33. static LIST_AUTH_CHAN    *authchan_malloc();
  34. static LIST_AUTH_MTA    *authmta_malloc();
  35.  
  36.  
  37.  
  38.  
  39. /* ------------------------  Begin  Routines  ------------------------------- */
  40.  
  41.  
  42.  
  43.  
  44. #ifdef lint
  45. /*VARARGS2*/
  46. void do_reason (au, str)
  47. AUTH   *au;
  48. char   *str;
  49. {
  50.     do_reason (au, str);
  51. }
  52.  
  53. #else
  54. void do_reason (va_alist)
  55. va_dcl
  56. {
  57.     va_list        ap;
  58.     AUTH        *au;
  59.  
  60.     va_start (ap);
  61.  
  62.     au = va_arg (ap, AUTH *);
  63.  
  64.     _asprintf (auth2submit_msg, NULLCP, ap);
  65.  
  66.     au -> reason = strdup (auth2submit_msg);
  67.     va_end (ap);
  68. }
  69. #endif
  70.  
  71.  
  72.  
  73.  
  74. LIST_AUTH_CHAN *authchan_new (value, def)    
  75. CHAN               *value;
  76. LIST_AUTH_CHAN        *def;
  77. {
  78.     LIST_AUTH_CHAN    *list;
  79.  
  80.  
  81.     PP_TRACE (("authchan_new (%x)", value)); 
  82.  
  83.     list = authchan_malloc();
  84.  
  85.     if (def)
  86.         *list = *def;    /* --- structure copy --- */
  87.     if (value) 
  88.         list -> li_chan = value;
  89.  
  90.     return (list);
  91. }
  92.  
  93.  
  94.  
  95.  
  96. void authchan_add (list, item)
  97. LIST_AUTH_CHAN        **list;
  98. LIST_AUTH_CHAN        *item;
  99. {
  100.     LIST_AUTH_CHAN    *lp = *list;
  101.  
  102.     PP_TRACE (("authchan_add()"));
  103.  
  104.     if (lp == NULLIST_AUTHCHAN) {
  105.         *list = item;
  106.         return;
  107.     }
  108.  
  109.     while (lp -> li_next != NULLIST_AUTHCHAN)
  110.         lp = lp -> li_next;
  111.     lp -> li_next = item;
  112. }
  113.  
  114.  
  115.  
  116.  
  117. void authmta_add (list, item)
  118. LIST_AUTH_MTA        **list;
  119. LIST_AUTH_MTA        *item;
  120. {
  121.     LIST_AUTH_MTA    *lp = *list;
  122.  
  123.     PP_TRACE (("authmta_add()"));
  124.  
  125.     if (lp == NULLIST_AUTHMTA) {
  126.         *list = item;
  127.         return;
  128.     }
  129.  
  130.     while (lp -> li_next != NULLIST_AUTHMTA)
  131.         lp = lp -> li_next;
  132.     lp -> li_next = item;
  133. }
  134.  
  135.  
  136.  
  137.  
  138. LIST_AUTH_MTA *authmta_new (value)
  139. char   *value;
  140. {
  141.     LIST_AUTH_MTA    *list;
  142.  
  143.     if (value == NULLCP)
  144.         return (NULLIST_AUTHMTA);
  145.  
  146.     PP_TRACE (("authmta_new ('%s')", value));
  147.  
  148.     list = authmta_malloc();
  149.     list -> li_mta = value;
  150.     return (list);
  151. }
  152.  
  153.  
  154.  
  155.  
  156. AUTH_USER *authusr_new()
  157. {
  158.     AUTH_USER *new;
  159.  
  160.     PP_TRACE (("authusr_new()"));
  161.     new = (AUTH_USER *) malloc (sizeof *new);
  162.     bzero ((char *)new, sizeof *new);
  163.  
  164.     new -> found        = FALSE;
  165.     new -> rights        = AUTH_RIGHTS_UNSET;
  166.     return (new);
  167. }
  168.  
  169.  
  170.  
  171.  
  172. AUTH *auth_new(isdr)
  173. int isdr;
  174. {
  175.     AUTH   *new;
  176.  
  177.     PP_TRACE (("auth_new()"));
  178.  
  179.     new = (AUTH *) malloc (sizeof *new);
  180.     bzero ((char *)new, sizeof *new);
  181.  
  182.     if (isdr)
  183.         new -> status    = AUTH_DR_OK;
  184.     else
  185.         new -> status     = AUTH_OK;
  186.  
  187.     new -> stage         = AUTH_STAGE_1;
  188.     new -> warnings        = AUTH_NOTWARNED;
  189.     new -> mta_inrights    = AUTH_RIGHTS_UNSET;
  190.     new -> mta_outrights    = AUTH_RIGHTS_UNSET;
  191.     new -> user_inrights    = AUTH_RIGHTS_UNSET;
  192.     new -> user_outrights    = AUTH_RIGHTS_UNSET;
  193.     return (new);
  194. }
  195.  
  196.  
  197.  
  198.  
  199. /* ------------------------  Static Routines  ------------------------------- */
  200.  
  201.  
  202.  
  203.  
  204. static LIST_AUTH_CHAN *authchan_malloc()
  205. {
  206.     LIST_AUTH_CHAN    *new;
  207.  
  208.     PP_TRACE (("authchan_malloc()"));
  209.     new = (LIST_AUTH_CHAN *) malloc (sizeof *new);
  210.     bzero ((char *)new, sizeof *new);
  211.  
  212.     new -> li_found        = FALSE;
  213.     new -> policy        = AUTH_CHAN_FREE;
  214.     return (new);
  215. }
  216.  
  217.  
  218.  
  219.  
  220. static LIST_AUTH_MTA *authmta_malloc()
  221. {
  222.     LIST_AUTH_MTA *new;
  223.  
  224.     PP_TRACE (("authmta_malloc()"));
  225.  
  226.     new = (LIST_AUTH_MTA *) malloc (sizeof *new);
  227.     bzero ((char *)new, sizeof *new);
  228.     
  229.     new -> li_found        = FALSE;
  230.     new -> rights        = AUTH_RIGHTS_UNSET;
  231.     return (new);
  232. }
  233.